package com.housekeeping.housekeeping.wxPay.config;

import com.github.wxpay.sdk.WXPayConfig;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public  class PayConfiguration implements WXPayConfig {
    private static String PAGE_FILE_NAME="wxPay.properties";
    private static String appId;
    private static String mchId;
    private static String key;
    private static int connectTimeoutMs;
    private static int readTimeoutMs;

    static {
        try {
            Properties properties = new Properties();
            properties.load(PayConfiguration.class.getClassLoader().getResourceAsStream(PAGE_FILE_NAME));
            appId=properties.getProperty("appId");
            mchId=properties.getProperty("mchId");
            key=properties.getProperty("key");
            connectTimeoutMs=Integer.parseInt(properties.getProperty("connectTimeoutMs"));
            readTimeoutMs=Integer.parseInt(properties.getProperty("readTimeoutMs"));
        } catch (IOException e) {
            System.out.println("[配置]\t获取微信支付配置信息失败");
            e.printStackTrace();
        }

    }

    @Override
    public String getAppID() {
        return appId;
    }

    @Override
    public String getMchID() {
        return mchId;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return connectTimeoutMs;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return readTimeoutMs;
    }
}
